// PosNormCol Shader

struct VS_IN
{
	float3 Pos	: POSITION;
	float3 Norm	: NORMAL;
	float4 diffuse 	: COLOR;
};

struct VS_OUT
{
	float4 Pos 	: SV_POSITION;
    float3 Norm 	: TEXCOORD0;
	float4 WorldPos : TEXCOORD1;
    float4 diffuse 	: COLOR;
};


matrix g_World : WORLD;
matrix g_WorldViewProj : WORLDVIEWPROJECTION;
float3 g_PosLight;


VS_OUT VS(VS_IN vIn)
{
	VS_OUT vOut = (VS_OUT)0;
	
	float4 hPos = float4(vIn.Pos,1);
	vOut.Pos = mul(hPos, g_WorldViewProj);
	vOut.WorldPos = mul(hPos, g_World);
	vOut.Norm = mul(vIn.Norm, (float3x3)g_World);
	vOut.Norm = normalize(vOut.Norm);
	vOut.diffuse = vIn.diffuse;
	
	return vOut;
}
 
float4 PS(VS_OUT pIn) : SV_Target
{
	return float4((saturate(dot(g_PosLight, pIn.Norm)) * pIn.diffuse).rgb, 1);
}

technique10 Render
{
    pass P0
    {
        SetVertexShader( CompileShader( vs_4_0, VS() ) );
        SetGeometryShader( NULL );
        SetPixelShader( CompileShader( ps_4_0, PS() ) );
    }
}



